package qlsl.androiddesign.adapter.subadapter;

import java.util.List;

import com.qlsl.androiddesign.kuaiwa.R;

import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.TextView;
import qlsl.androiddesign.activity.baseactivity.BaseActivity;
import qlsl.androiddesign.adapter.baseadapter.BaseAdapter;
import qlsl.androiddesign.entity.otherentity.PostingComment;
import qlsl.androiddesign.util.commonutil.ImageUtils;
import qlsl.androiddesign.util.commonutil.TimeFormatUtils;

/**
 * 帖子评论列表<br/>
 */
public class PostingCommentAdapter extends BaseAdapter<PostingComment> {

	public PostingCommentAdapter(BaseActivity activity, List<PostingComment> list) {
		super(activity, list);
	}

	public View getView(int position, View convertView, ViewGroup parent) {
		convertView = getItemView(convertView, R.layout.listitem_posting_comment);

		ImageView iv_icon = getView(convertView, R.id.iv_icon);
		TextView tv_name = getView(convertView, R.id.tv_name);
		TextView tv_time = getView(convertView, R.id.tv_time);
		TextView tv_content = getView(convertView, R.id.tv_content);

		PostingComment item = getItem(position);
		String name = item.getUsername();
		String time = TimeFormatUtils.format(item.getTime());
		String content = item.getComment();

		ImageUtils.circle(activity, item.getHeadphoto(), iv_icon);
		tv_content.setText(content);
		tv_name.setText(name);
		tv_time.setText(time);

		return convertView;
	}
}
